package com.ita.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ita.service.UserService;

//@WebServlet("/regis")
public class RegisterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private UserService userService;

	public RegisterServlet() {
		userService = new UserService();
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		request.setCharacterEncoding("utf-8");
		String info = userService.judge(request);
		if ("legal".equals(info)) {
			response.sendRedirect("suc");
		} else {
			request.setAttribute("failTip", info);
			request.getRequestDispatcher("/fail").forward(request, response);
		}
	}
}
